<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <form class="layui-form" lay-filter="myform" id="myform">
                	<input type="reset" id="btReset" class="layui-hide" >
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" id="name"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group">
                                <button type="button" class="layui-btn layui-btn-primary" data-type="query"><i class="layui-icon">&#xe615;</i>查询</button>
                                <button type="button" class="layui-btn layui-btn-primary" data-type="resetBtn"><i class="layui-icon">&#xe669;</i>重置</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="layui-hide"  id="main-table" lay-filter="main-table"></table>
            </div>
        </div>
    </div>
</div>

<script th:inline="none"></script>
<script>
let userId = `[[${session.me.id}]]`;
layui.use(['table','form','element'], function(){
    var table = layui.table,
    element = layui.element,
    form = layui.form;
    table.render({
        elem: '#main-table'
        ,height: 540
        ,url: 'paper/getPageList'
        ,title: '试卷列表'
        ,page: true 
        ,cols: [
            [ 
                {type: 'radio'}
                ,{field: 'name', title: "试卷名称",width:280}
                ,{field: 'code',title: "编号",width:90}
                ,{field: 'beginDate',title: "开始日期",width:110}
                ,{field: 'endDate',title: "结束日期",width:110}
            ]
        ]
        ,done:function(){
        }
    });
    table.on('row(main-table)', function(obj){
    	clickLayTableRow(table,form,'main-table',obj);
    });
    window.getId = function(){
    	var checkStatus = table.checkStatus('main-table'); 
    	var data = checkStatus.data;
    	if(data.length===0){
    		return {name:'',id:''};
    	}else{
    		return {id:data[0].id,name:data[0].name};
    	}
    	
    }
    var $ = layui.$, active = {
        query: function(){

            table.reload("main-table",{where:{name:$("#name").val()}})
        },
        resetBtn:function () {
            $("#btReset").click();
                
        }
    };

    $('.layui-form .layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });

    });
    
</script>
</body>
</html>